Merged
Conversation
archie-mckenzie
approved these changes
Mar 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Greptile Summary
This PR fixes a bug in
gt-fastapiwhere eager loading of translations was skipped wheneverlocaleswas not explicitly passed toinitialize_gt(), even if locales were correctly resolved from a config file.Key changes:
_setup.py: The eager-loading guard changed fromif eager_loading and locales:toif eager_loading and resolved_locales:.resolved_localesis the merged result of the function argument and the config-file fallback, so this correctly enables preloading when locales are defined only ingt.config.json.venerable-shaman-mielikki.md) is included to track the version bump forpypi/gt-fastapi.Confidence Score: 5/5
resolved_localesalready accounts for theNonecase and the config-file fallback. No new dependencies, no structural changes, and the existing lifespan/middleware wiring is untouched.Important Files Changed
resolved_locales(which includes config-file fallback) instead of the rawlocalesparameter, which could beNoneeven when locales are defined in the config file.pypi/gt-fastapito accompany the bug fix.Sequence Diagram
sequenceDiagram participant App as FastAPI App participant init as initialize_gt() participant cfg as load_gt_config() participant mgr as I18nManager participant cdn as CDN / Translation Store App->>init: initialize_gt(app, locales=None, eager_loading=True, ...) init->>cfg: load_gt_config() cfg-->>init: file_config (may include locales) init->>init: resolved_locales = locales or file_config.get("locales") init->>mgr: I18nManager(resolved_locales, ...) init->>App: wrap lifespan → _gt_lifespan Note over App,cdn: At startup (lifespan) App->>init: _gt_lifespan triggered alt eager_loading AND resolved_locales init->>mgr: load_all_translations() mgr->>cdn: fetch translations for each locale cdn-->>mgr: translation data else no locales or eager_loading=False Note over init,mgr: skip preloading end Note over App,mgr: Per-request middleware App->>init: HTTP request arrives init->>init: detect locale (Accept-Language or get_locale()) init->>mgr: set_locale(locale) mgr-->>App: locale set for request scopeLast reviewed commit: cb0b561